<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <script type="text/javascript" src="../../util/js/jquery.js"></script>
    <script type="text/javascript" src="https://cdn.staticfile.org/plupload/2.1.5/plupload.full.min.js"></script>
    <script type="text/javascript" src="dist/qiniu.min.js"></script>
    <script>
        var uploader;
        $(function(){
            var uploader = Qiniu.uploader({
                runtimes: 'html5,flash,html4',
                browse_button: 'pickfiles',
                container: 'container',
                drop_element: 'container',
                max_file_size: '1000mb',
                flash_swf_url: 'https://cdn.staticfile.org/plupload/2.1.5/Moxie.swf',
                dragdrop: true,
                chunk_size: '4mb',
                uptoken_url: "/pro_jnd_new/index/qiniuToken",
                // uptoken_func: function(){
                //     var ajax = new XMLHttpRequest();
                //     ajax.open('GET', $('#uptoken_url').val(), false);
                //     ajax.setRequestHeader("If-Modified-Since", "0");
                //     ajax.send();
                //     if (ajax.status === 200) {
                //         var res = JSON.parse(ajax.responseText);

                //         return res.uptoken;
                //     } else {

                //         return '';
                //     }
                // },
                domain: 'http://omlx6k4f3.bkt.clouddn.com',
                get_new_uptoken: false,
                // downtoken_url: '/downtoken',
                // unique_names: true,
                // save_key: true,
                // x_vars: {
                //     'id': '1234',
                //     'time': function(up, file) {
                //         var time = (new Date()).getTime();
                //         // do something with 'time'
                //         return time;
                //     },
                // },
                auto_start: true,
                log_level: 5,
                init: {
                    'FilesAdded': function(up, files) {
                    },
                    'BeforeUpload': function(up, file) {

                    },
                    'UploadProgress': function(up, file) {

                    },
                    'UploadComplete': function() {
                        alert('a');
                    },
                    'FileUploaded': function(up, file, info) {

                    },
                    'Error': function(up, err, errTip) {

                    }
                    // ,
                    // 'Key': function(up, file) {
                    //     var key = "";
                    //     // do something with key
                    //     return key
                    // }
                }
            });
        })
        function ffff(){
            uploader.start();
        }
    </script>
</head>
<body>

<div id="container">
    <a class="btn btn-default btn-lg " id="pickfiles" href="#" >
        <i class="glyphicon glyphicon-plus"></i>
        <span>选择文件</span>
    </a>
</div>

<a href="javascript:ffff();" id="btn">ok</a>
</body>

</html>